package com.hualan.controller;

import com.hualan.pojo.FM;
import com.hualan.pojo.PageResult;
import com.hualan.pojo.Result;
import com.hualan.service.FMService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/fm")
public class FMController {
    @Autowired
    private FMService fmService;

    @GetMapping("/search")
    public Result queryAllFm(String title, @RequestParam  (defaultValue = "1") Integer page,@RequestParam (defaultValue = "10") Integer pageSize) {
        PageResult pageResult = fmService.queryAllFm(title, page, pageSize);
        return Result.success(pageResult);
    }

    @PostMapping("/add")
    public Result addFm(@RequestBody FM fm) {
        Result result = fmService.addFm(fm);
        return result;
    }

    @PutMapping("/update")
    public Result updateFm(@RequestBody FM fm) {
        Result result = fmService.updateFm(fm);
        return result;
    }

    @PutMapping("/delete")
    public Result deleteFm(@RequestBody List<Integer> ids) {
        Result result = fmService.deleteFm(ids);
        return result;
    }

}
